home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1
/
Ian and Stuart's One (Australia).iso
/
Australasian Legends
/
Commercial
/
Rainbow Hill
/
MacDOS™ 2.0.0
/
batches
/
movefile.bat
< prev
next >
Wrap
DOS Batch File
|
1994-06-30
|
2KB
|
65 lines
@echo off
! movefile.bat Batch file to move a file
!
! movefile name [dest]
!
! where 'name' is the file to be moved and 'dest' is the path of the
! destination folder. 'name' can be preceded by a path and a volume ID.
! If 'dest' is missing, the current directory is used as destination.
!
! movefile.bat calls extractName and uniqueTempName
!
! Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
!
! ensure that the first parameter is there and that the third one is not
set doserr=13
if not "%3 " == " " goto ERR_LBL
if "%1 " == " " goto ERR_LBL
! ensure that the requested file is there
set doserr=27
if not exist "%1" goto ERR_LBL
! determine the destination folder
set movefile_folder=%WHERE%
if "%2 " == " " goto FOLDER_OK_LBL
if not existdir "%2" goto ERR_LBL
set movefile_folder=%2
:FOLDER_OK_LBL
! copy the file
set doserr=0
onerror ERR_LBL
call extractName "%1" movefile_name
if not %doserr% == 0 goto ERR_LBL
copy "%1" "%movefile_folder%\%movefile_name%"
! Remove the source but only if it does not coincide with the destination. There
! could be aliased folders in the paths. Therefore, we cannot simply compare the
! two path strings. We have to rename the destination, delete the source
! (which we might fail to find), and finally revert the name of the destination
! to what it was before the first renaming.
! get a unique file name and rename the destination
call uniqueTempName movefile_temp "%movefile_folder%"
ren "%movefile_folder%\%movefile_name%" "%movefile_temp%"
! delete the source and re-rename the destination
onerror SKIP_LBL
del "%1"
:SKIP_LBL
onerror ERR_LBL
ren "%movefile_folder%\%movefile_temp%" "%movefile_name%"
set doserr=0
goto DONE_LBL
:ERR_LBL
show %doserr%
:DONE_LBL
! remove the global variables
set movefile_name=
set movefile_temp=
set movefile_folder=